package edu.usx.server.mapper;

import edu.usx.server.pojo.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import edu.usx.server.pojo.dto.UserregisterDto;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author RawMieEgg

 */

@Mapper
public interface UserMapper extends BaseMapper<User> {
    @Update("UPDATE users SET role_id = #{role_id} WHERE id = #{id}")
    void update(User user);

    /**
     * 用户注册
     * @param user
     */
    @Insert("insert into users(name, phone, username, password,email,create_time, update_time) values (#{name}, #{phone}, #{username}, #{password},#{email},#{create_time}, #{update_time}) ")
    void register(UserregisterDto user);

    @Select("select * from users where username=#{username}")
    UserregisterDto selectusername(UserregisterDto user);
}
